<template>
  <div class="multiselect-toolbar">
    <div class="multiselect-info">
      <span class="multiselect-count">已选择 {{ selectedCount }} 条消息</span>
    </div>
    <div class="multiselect-actions">
      <button
        class="multiselect-btn multiselect-btn-confirm"
        title="确认选择"
        :disabled="selectedCount <= 1"
        @click="onConfirm"
      >
        确认
      </button>
      <button class="multiselect-btn multiselect-btn-exit" title="退出多选" @click="onExit">
        退出
      </button>
    </div>
  </div>
</template>

<script lang="ts" setup>
// 组件属性
const props = defineProps<{
  selectedCount: number
  hasSelectedMessages: boolean
  totalCount: number
}>()

// 组件事件
const emit = defineEmits<{
  (e: 'exit'): void
  (e: 'confirm'): void
}>()

// 处理确认选择
const onConfirm = (): void => {
  if (props.selectedCount > 1) {
    emit('confirm')
  }
}

// 处理退出多选模式
const onExit = (): void => {
  emit('exit')
}
</script>

<style scoped>
/* 多选操作栏 */
.multiselect-toolbar {
  flex-shrink: 0;
  height: 46px;
  padding: 0 16px;
  background: var(--primary-color-light);
  border-top: 1px solid var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.multiselect-info {
  display: flex;
  align-items: center;
}

.multiselect-count {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--primary-color-dark);
}

.multiselect-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.multiselect-btn {
  padding: 5px 10px;
  border: 1px solid var(--primary-color);
  border-radius: var(--border-radius-base);
  background: transparent;
  color: var(--primary-color);
  font-size: var(--font-size-small);
  cursor: pointer;
  transition: all var(--transition-duration) var(--transition-timing-function);
}

.multiselect-btn:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
}

.multiselect-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.multiselect-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border-color-normal);
  color: var(--text-color-tertiary);
}

/* 确认按钮样式 */
.multiselect-btn-confirm {
  background-color: var(--success-color, #4caf50);
  color: white;
  border-color: var(--success-color, #4caf50);
}

.multiselect-btn-confirm:hover:not(:disabled) {
  background-color: var(--success-color-hover, #3d8b40);
  border-color: var(--success-color-hover, #3d8b40);
}

/* 退出按钮样式 */
.multiselect-btn-exit {
  background-color: var(--primary-color);
  color: white;
}

.multiselect-btn-exit:hover {
  background-color: var(--primary-color-dark);
}

/* 深色主题适配 */
[data-theme='dark'] .multiselect-toolbar {
  background: rgba(var(--primary-color-rgb), 0.2);
  border-color: var(--primary-color-dark);
}

[data-theme='dark'] .multiselect-count {
  color: var(--text-color-primary);
}

[data-theme='dark'] .multiselect-btn {
  border-color: var(--primary-color-light);
  color: var(--primary-color-light);
}

[data-theme='dark'] .multiselect-btn:hover:not(:disabled) {
  background: var(--primary-color-light);
  color: var(--background-color-primary);
}

[data-theme='dark'] .multiselect-btn-confirm {
  background-color: var(--success-color, #4caf50);
  color: white;
  border-color: var(--success-color, #4caf50);
}

[data-theme='dark'] .multiselect-btn-confirm:hover:not(:disabled) {
  background-color: var(--success-color-hover, #3d8b40);
  border-color: var(--success-color-hover, #3d8b40);
}
</style>
